package com.gome.extract.common;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Properties;
import java.util.ResourceBundle;


public class GlobalUtils
{
    public static final String ENCODE = "UTF8";
    public static final String TAB = "\t";
    public static final String SEP = "@@";//分隔符
    public static final String CON  = "##";//拼接符
    public static final String COL = ":";

	public String trimValue(String s)
	{
		String t = "";
		for(int i=0; i<s.length(); ++i)
		{
			if((s.charAt(i)=='\n')||(i+1<s.length()-1 && s.charAt(i)==' ' && s.charAt(i+1)==' '))
				continue;
			if((i==0 || i==s.length()-1)&&s.charAt(i)==' ')
				continue;
			t += s.charAt(i);
		}
		return t.trim();
	}
	
	
	public  byte[] intToByte(int a)
	{  
	    return new byte[] {  
	        (byte) ((a >> 24) & 0xFF),  
	        (byte) ((a >> 16) & 0xFF),     
	        (byte) ((a >> 8) & 0xFF),     
	        (byte) (a & 0xFF)  
    	};  
	}  
	     
	public  byte[] longToByte(long a) 
	{ 
		 return new byte[] {  
				 	(byte) ((a >> 56) & 0xFF),  
			        (byte) ((a >> 48) & 0xFF),     
			        (byte) ((a >> 40) & 0xFF),     
			        (byte) ((a >> 32) & 0xFF), 
			        (byte) ((a >> 24) & 0xFF),  
			        (byte) ((a >> 16) & 0xFF),     
			        (byte) ((a >> 8) & 0xFF),     
			        (byte) (a & 0xFF)  
		    	};  
	} 
	
	public  int byteToInt(byte[] b, int pos) 
	{  
	    return  ((b[pos+3] & 0xFF)   |  
	            ((b[pos+2]<<8) & 0xFF00)  |  
	            ((b[pos+1]<<16) & 0xFF0000) |  
	            ((b[pos]<<24) & 0xFF000000));  
	}  

	public long byteToLong(byte[] b, int pos) 
	{ 
	    return  ((long)b[pos+7] & 0xFFL) | 
			(((long)b[pos+6]<<8) & 0xFF00L)  | 
			(((long)b[pos+5]<<16) & 0xFF0000L) | 
			(((long)b[pos+4]<<24) & 0xFF000000L) |
			(((long)b[pos+3]<<32) & 0xFF00000000L) | 
			(((long)b[pos+2]<<40) & 0xFF0000000000L) |
			(((long)b[pos+1]<<48) & 0xFF000000000000L) |
			(((long)b[pos+0]<<56) & 0xFF00000000000000L); 
	}
}

